
#include <map.h>

void map_init(struct map *mp)
{
	mp->len = 0;
}

void map_free(struct map *mp)
{
}

int map_get(struct map *mp, uintptr_t addr)
{
	int i;

	for (i = 0; i < mp->len; i++)
		if (mp->arr[i].first == addr)
			return i;
	return -1;
}

int map_put(struct map *mp, uintptr_t addr)
{
	mp->arr[mp->len].first = addr;
	mp->len++;
	return mp->len -1;
}

void map_setvalue(struct map *mp, uintptr_t addr, uintptr_t value)
{
	int i;

	for (i = 0; i < mp->len; i++)
		if (mp->arr[i].first == addr)
		{
			mp->arr[i].second = value;
			return;
		}
}

uintptr_t map_getvalue(struct map *mp, uintptr_t addr)
{
	int i;

	for (i = 0; i < mp->len; i++)
		if (mp->arr[i].first == addr)
			return mp->arr[i].second;

	return NULL;
}

